package com.beiing.tianshuai.tianshuai.interest.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CodeBean;
import com.beiing.tianshuai.tianshuai.entity.FollowResultBean;
import com.beiing.tianshuai.tianshuai.interest.entity.InterestVideoDetailBean;
import com.beiing.tianshuai.tianshuai.interest.model.InterestVideoDetailModel;
import com.beiing.tianshuai.tianshuai.interest.model.InterestVideoDetailModelImpl;
import com.beiing.tianshuai.tianshuai.interest.view.InterestVideoDetailViewImpl;

/**
 * Created by Jinni on 2017/12/3 0003
 */

public class InterestVideoDetailPresenter extends BasePresenter implements InterestVideoDetailPresenterImpl,
        InterestVideoDetailModel.OnInterestVideoDetailResponseListener {


    private InterestVideoDetailViewImpl mView;
    private InterestVideoDetailModelImpl mModel;

    public InterestVideoDetailPresenter(InterestVideoDetailViewImpl view) {
        mView = view;
        mModel = new InterestVideoDetailModel(this);
    }

    /**
     * 获取视频详情
     * @param vid      视频id
     * @param lastId   最后一条评论的id
     * @param pageSize page size
     * @param pageNum  当前页码
     * @param uid
     * @param code
     */
    @Override
    public void getVideoDetail(String vid, String lastId, String pageSize, int pageNum, String uid, int code) {
        mView.showProgress();
        mModel.getVideoDetail(vid, lastId, pageSize, pageNum, uid, code);
    }

    @Override
    public void getMoreReply(String vid, String lastCid, String pageSize, int pageNum, String uid, String lastRid, int code) {
        mModel.getMoreReply(vid, lastCid, pageSize, pageNum, uid, lastRid, code);
    }

    @Override
    public void submitReply(String vid, String uid, String toUid, String content) {
        mModel.submitReply(vid, uid, toUid, content);
    }

    @Override
    public void getPraiseResult(String vid, String uid, String controller) {
        mModel.getPraiseResult(vid, uid, controller);
    }

    @Override
    public void setFollowed(String uid, String toUid) {
        mModel.setFollowed(uid, toUid);
    }

    @Override
    public void setPraiseReply(String id, String vid, String uid, String toUid) {
        mModel.setPraiseReply(id, vid, uid, toUid);
    }

    @Override
    public void deleteReply(String cid, String uid, int position, String type) {
        mModel.deleteReply(cid, uid, position, type);
    }

    @Override
    public void addCommentReply(String vid, String repliedRId, String uid, String toUid, String content, String originalContent, String replyType, String repliedCId) {
        mModel.addCommentReply(vid, repliedRId, uid, toUid, content, originalContent, replyType, repliedCId);
    }

    @Override
    public void setPraiseCommentReply(String cid, String vid, String uid, String toUid, String rid) {
        mModel.setPraiseCommentReply(cid, vid, uid, toUid, rid);
    }

    @Override
    public void onGetDetailSuccess(InterestVideoDetailBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onGetDetailError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }

    @Override
    public void onGetMoreReplySuccess(InterestVideoDetailBean bean) {
        mView.getMoreReplySuccess(bean);
    }

    @Override
    public void onGetMoreReplyError(Throwable throwable) {
        mView.getMoreReplyError(throwable);
    }

    @Override
    public void onAddReplySuccess(CodeBean bean) {
        mView.getAddReplySuccess(bean);
    }

    @Override
    public void onAddReplyError(Throwable throwable) {
        mView.getAddReplyError(throwable);
    }

    @Override
    public void onFollowedSuccess(FollowResultBean bean) {
        mView.onFollowedSuccess(bean);
    }

    @Override
    public void onFollowedError(Throwable throwable) {
        mView.onFollowedError(throwable);
    }

    @Override
    public void onDelReplySuccess(CodeBean bean, int position) {
        mView.onDelReplySuccess(bean, position);
    }

    @Override
    public void onDelReplyError(Throwable throwable) {
        mView.onDelReplyError(throwable);
    }
}
